package com.fastjars.business.spring.fastjson.filter;

import com.alibaba.fastjson.serializer.PropertyFilter;
import org.apache.commons.util.StringUtils;

/**
 * AbsProperty
 * 控制字段显示隐藏
 * @author Brant Liu <br>
 * 邮箱：lbf1988@qq.com <br>
 * 日期：2018/5/4
 * @version 1.0.0
 */
public abstract class AbsProperty extends AbsBase implements PropertyFilter {
    /**
     * 设置不需要显示的对象字段
     * @return
     */
    public abstract String[] setFilterField();

    @Override
    public boolean apply(Object object, String name, Object value) {
        if(StringUtils.isBlank(setFilterField())){
            return true;
        }
        if(checkObject(object)) {
            for (String field : setFilterField()) {
                if (name.equalsIgnoreCase(field)) {
                    return false;
                }
            }
        }
        return true;
    }
}
